<?php
//把文章写到数据库里去
session_start();
$title=$_POST['title'];
$class=$_POST['artclass'];
$postdata=getdate();
$content=$_POST['content'];
if($title=="" || $content=="")
{
    echo "<script>alert('标题或文章内容不能为空!!'); window.location.href='addart.php';</script>";
}
else
{
 function addart($title,$class,$postdata,$content)
{
require_once("conn.php");
    $sql_insert="insert into artcontent (cs_id,Postdata,Title,Content)values('$class',NOW(),'$title','$content');";
    $sql_addart_num="UPDATE  artclass SET artnum=artnum+1 WHERE cs_id='$class'";
    if(mysql_query($sql_insert) && mysql_query($sql_addart_num)) 
    echo "<script>alert('添加文章成功!!'); window.location.href='artlist.php';</script>";   
}
addart($title,$class,$postdata,$content);
}

?>